<?php

namespace app\model;

use app\BaseModel;
use app\model\not_del\RatingScaleModel as NotDelRatingScaleModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 职业测评结果
 */
class MetierEvaluationResultModel extends BaseModel
{
    protected $name = 'metier_evaluation_result';

    /**
     * 关联量表
     * @return BelongsTo
     */
    public function ratingScale(): BelongsTo
    {
        return $this->belongsTo(NotDelRatingScaleModel::class, 'rating_scale_id')->bind([
            'rating_scale_type_name',
            'rating_scale_name' => 'name',
            'previous_name',
            'mode_name'
        ]);
    }

    /**
     * 关联因子预警
     * @return BelongsTo
     */
    public function ratingScaleFactorWarning(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorWarningModel::class,'warning_id')->bind([
            'warning_name' => 'name',
            'mark_id',
            'mark_count',
            'mark_color_id',
            'factor_name',
            'factor_id'
        ]);
    }

    /**
     * 关联自评因子
     * @return HasMany
     */
    public function factorScore(): HasMany
    {
        return $this->hasMany(MetierFactorScoreModel::class,'result_id');
    }
}